package com.zhima.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author : Administer
 * @date : 2023-10-09 16:36
 **/
@Configuration
public class RestTemplateConfiguration {
    @Bean //必须new 一个RestTemplate并放入spring容器当中,否则启动时报错
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
        simpleClientHttpRequestFactory.setConnectTimeout(30 * 3000);
        simpleClientHttpRequestFactory.setReadTimeout(30 * 3000);
        return new RestTemplate(simpleClientHttpRequestFactory);
    }
}
